package crm.base.entity;

import java.io.Serializable;

import org.apache.commons.lang3.builder.ToStringBuilder;

public abstract class BaseEntity implements Serializable {

	private static final long serialVersionUID = -3123201296082156288L;

	private Integer id;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	@Override
	public int hashCode() {
		return this.getId() == null ? super.hashCode() : this.getId().hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof BaseEntity)
			return this.getId() == null ? super.equals(obj) : this.getId().equals(((BaseEntity) obj).getId());
		return super.equals(obj);
	}
	
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
